home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / fpkpas92.zip / SRCRTL.ZIP / RTL / DOS / PIXEL.PPI < prev    next >
Text File  |  1997-07-01  |  5KB  |  152 lines

  1. { File PIXEL.PPI }
  2.  
  3. procedure putpixel(x,y:integer;colour:longint);
  4. var viewport:viewporttype;
  5. begin
  6. if aktviewport.clip then viewport:=aktviewport else viewport:=aktscreen;
  7.   asm
  8.       xorl   %eax,%eax
  9.       movl   %eax,%ebx
  10.       movw   x,%bx
  11.       movw   y,%ax
  12.       addw   _AKTVIEWPORT,%bx
  13.       addw   _AKTVIEWPORT+2,%ax
  14.       cmpw   viewport,%bx
  15.       jl     p_exit                        // wenn x < x1 Ende
  16.       cmpw   -8(%ebp),%bx
  17.       jg     p_exit                        // wenn x > x2 Ende
  18.       cmpw   -10(%ebp),%ax
  19.       jl     p_exit                        // wenn y < y1 Ende
  20.       cmpw   -6(%ebp),%ax
  21.       jg     p_exit                        // wenn y > y2 Ende
  22.       movl   _Y_ARRAY(,%eax,4),%eax
  23.       addl   _X_ARRAY(,%ebx,4),%eax     
  24.       movl   %eax,%esi
  25.       movl   _WINSHIFT,%ecx                // { offset / winsize        }
  26.       shrl   %cl,%eax                      // 
  27.       cmpl   _AW_BANK,%eax                 // { same bank ?             }
  28.       je     p_dont_switch                 // { yep                     } 
  29.       movl   %eax,_AW_BANK                 // { newbank                 }
  30.       pushl  %eax                          // 
  31.       movl   _BANKSWITCHPTR,%eax           // { switchbank              }
  32.       call   %eax                          //
  33.   p_dont_switch:
  34.       andl   _WINLOMASK,%esi
  35.       movl   colour,%eax
  36.       addl   _WBUFFER,%esi
  37.       movw   _SEG_WRITE,%bx
  38.       movw   _BYTESPERPIXEL,%cx
  39.       movw   %ds,%dx
  40.       movw   %bx,%ds
  41.       testl  $1,%ecx
  42.       jz     pp_2BPP
  43.       movb   %al,(%esi)
  44.       jnz    pp_exit
  45.   pp_2BPP:
  46.       movw   %ax,(%esi)
  47.   pp_exit:
  48.       movw   %dx,%ds
  49.   p_exit:
  50.   end; 
  51. end; { proc }
  52.  
  53. procedure pixel(offset:longint);
  54.  { wird nur intern aufgerufen, umrechnung auf Viewport und Range- }
  55.  { checking muessen von aufrufender Routine bereits erledigt sein }
  56.  { Bankswitching wird durchgefuehrt }  
  57.  begin
  58.    asm
  59.       movl   offset,%eax             
  60.       movl   %eax,%esi
  61.       movl   _WINSHIFT,%ecx                // { offset / winsize        }
  62.       shrl   %cl,%eax                      // 
  63.       cmpl   _AW_BANK,%eax                 // { same bank ?             }
  64.       je     dont_switch                   // { yep                     } 
  65.       movl   %eax,_AW_BANK                 // { newbank                 }
  66.       pushl  %eax                          // 
  67.       movl   _BANKSWITCHPTR,%eax           // { switchbank              }
  68.       call   %eax                          //
  69.  dont_switch:
  70.       movl   _WINLOMASK,%eax
  71.       andl   %eax,%esi
  72.       movl   _AKTCOLOR,%eax
  73.       movzwl _AKTWRITEMODE,%ecx
  74.       movw   _BYTESPERPIXEL,%bx
  75.       addl   _WBUFFER,%esi
  76.       movw   _SEG_WRITE,%dx
  77.       movw   %ds,%di
  78.       movw   %dx,%ds
  79.       testl  %ecx,%ecx
  80.       jz     dmove
  81.       shrl   %ebx
  82.       jnc    dxor2BPP
  83.       xorb   %al,(%esi)
  84.       jnc    pd_exit
  85.  dxor2BPP:
  86.       xorw   %ax,(%esi)
  87.       jnc    pd_exit 
  88.  dmove:      
  89.       shrl   %ebx
  90.       jnc    dmove2BPP
  91.       movb   %al,(%esi)
  92.       jc     pd_exit
  93.  dmove2BPP:
  94.       movw   %ax,(%esi)  
  95.  pd_exit:
  96.       movw   %di,%ds 
  97.    end; 
  98. end; { proc }
  99.  
  100. function getpixel(x,y:integer):longint;
  101. var viewport:viewporttype;
  102. begin
  103. if aktviewport.clip then viewport:=aktviewport else viewport:=aktscreen;
  104.   asm
  105.       movswl x,%ebx
  106.       movswl y,%eax
  107.       addw   _AKTVIEWPORT,%bx
  108.       addw   _AKTVIEWPORT+2,%ax
  109.       cmpw   viewport,%bx
  110.       jl     gp_exit                        // wenn x < x1 Ende
  111.       cmpw   -8(%ebp),%bx
  112.       jg     gp_exit                        // wenn x > x2 Ende
  113.       cmpw   -10(%ebp),%ax
  114.       jl     gp_exit                        // wenn y < y1 Ende
  115.       cmpw   -6(%ebp),%ax
  116.       jg     gp_exit                        // wenn y > y2 Ende
  117.       movl   _Y_ARRAY(,%eax,4),%eax
  118.       addl   _X_ARRAY(,%ebx,4),%eax     
  119.       movl   %eax,%esi
  120.       movl   _WINSHIFT,%ecx                // { offset / winsize        }
  121.       shrl   %cl,%eax                      // 
  122.       cmpl   _AW_BANK,%eax                 // { same bank ?             }
  123.       je     g_dont_switch                 // { yep                     }
  124.       pushl  %esi                          // { save Offset             }       
  125.       movl   %eax,_AW_BANK                 // { newbank                 }
  126.       pushl  %eax                          // 
  127.       movl   _BANKSWITCHPTR,%eax           // { switchbank              }
  128.       call   %eax                          //
  129.       popl   %esi                          // { restore Offset          }
  130.   g_dont_switch:
  131.       movl   _WINLOMASK,%eax
  132.       andl   %eax,%esi
  133.       xorl   %eax,%eax
  134.       movl   _BYTESPERPIXEL,%edx
  135.       addl   _WBUFFER,%esi   
  136.       movw   _SEG_WRITE,%bx
  137.       movw   %ds,%cx
  138.       movw   %bx,%ds   
  139.       testl  $1,%edx                       // { 1 or 2 BytesPerPixel ? }
  140.       jnz    g_8BPP
  141.       movw   %ds:(%esi),%ax
  142.       jnz    g_Result
  143.   g_8BPP:    
  144.       movb   %ds:(%esi),%al
  145.   g_Result:    
  146.       movw   %cx,%ds
  147.       movl   %eax,__RESULT 
  148.   gp_exit:
  149.   end;
  150. end; { proc }
  151.  
  152.